def sortColumns(matrix): # DO NOT modify this line 
    # TODO: add your code here
    num_rows = len(matrix)
    num_cols = len(matrix[0])
    transposed = list(map(list, zip(*matrix)))
    sorted_cols = [sorted(col) for col in transposed]
    result = list(map(list, zip(*sorted_cols)))
    return result
    return # You can modify or delete this line

# === DO NOT modify the code below === 
def main():
    mx1 = []
    n = int(input())
    for i in range(n):
        numbers = [ eval(x) for x in input().split() ]
        mx1.append(numbers)
    mx2 = sortColumns(mx1)
    for row in mx2:
        print(" ".join(map(str,row)))
    
if __name__ == "__main__":
    main()
# === DO NOT modify the code above ===